<?php
include 'header.php';
@$workers = dbSelectAll('select imgUrl,worker.name as worker_name,worker.id as worker_id,role.name as role_name,branch.name as branch_name,branch.id as branch_id,login,password,in_date from worker
							left join role on worker.role_id=role.id left join user on worker.user_id=user.id left join branch on worker.branch_id=branch.id order by worker.id asc');
?>
				<div class='col-xs-10'>
					<div class='panel panel-primary'>
   						<div class='panel-heading'>
   							<div class='row'>
   								<div class='col-xs-8'>
   									<div class='panel-title'>所有部门列表</div>
   								</div>
   								<div class='col-xs-2'>
   									<a href='addWorker.php' style='color:#000;'>添加职员</a>
   								</div>
   							</div>
   						</div>
   						<table class='typeTable table table-bordered'>
   							<tr>
   								<th>头像</th>
   								<th>名称</th>
   								<th>职位</th>
   								<th>登录名</th>
   								<th>登录密码</th>
   								<th>详细</th>
   								<th>操作</th>
   							</tr>
   							<?php foreach($workers as $worker){
   								@$branch_name = dbSelect('select worker.name from worker join branch on worker.branch_id=branch.id join role on worker.role_id=role.id where worker.branch_id=:id and role.id=2',
   															array('id'=>$worker['branch_id']));
   							?>
	   							<tr>
	   								<td><img src='img/worker/<?php echo $worker['imgUrl'];?>' class='smallImg' /></td>
	   								<td><?php echo $worker['worker_name'];?></td>
	   								<td><?php echo $worker['role_name'];?></td>
	   								<td><?php echo $worker['login'];?></td>
	   								<td><?php echo $worker['password'];?></td>
	   								<td>
	   									<a href='#lookWorker<?php echo $worker['worker_id'];?>' data-toggle='modal'>其他</a>
	   									<div class='modal' id='lookWorker<?php echo $worker['worker_id'];?>'>
											<div class='modal-dialog'>
												<div class='modal-content'>
													<div class='modal-header'>
														<div class='modal-title'>职员[<?php echo $worker['worker_name'];?>]其他信息</div>
													</div>
													<div class='modal-body'>
														<table class='table table-bordered'>
															<tr>
																<th>姓名</th>
																<th>部门</th>
																<th>部门主管</th>
																<th>入职日期</th>
															</tr>
															<tr>
																<td><?php echo $worker['worker_name'];?></td>
																<td><?php echo $worker['branch_name'];?></td>
																<td><?php echo $branch_name['name'];?></td>
																<td><?php echo $worker['in_date'];?></td>
															</tr>
														</table>
													</div>
													<div class='modal-footer'>
														<a class='btn btn-default' data-dismiss='modal'>返回</a>
													</div>
												</div>
											</div>
										</div>
	   								</td>
	   								<td>
	   									<a href='ediWorkerBasic.php?worker_id=<?php echo $worker['worker_id'];?>'>编辑</a>
	   									<a href='#delWorker<?php echo $worker['worker_id'];?>' data-toggle='modal'>删除</a>
	   								</td>
	   							</tr>
	   						<?php }?>
   						</table>
   						<div class='panel-body'>
   							<a href='index.php' class='btn btn-default'>返回</a>
   						</div>
   					</div>
				</div>
			</div>
		</div>
	<script>
		$(function(){
			
		});
	</script>  
	</body>
</html>